<h2><%= t 'cartasur.users.profile.title' %></h2>

<%= error_messages_for :cartasur_user %>
<% if flash[:error] %>
    <div style="color: #a11328;" class="error"><%= flash[:error] %></div>
<% end %>
<div id="page">
  <% if flash[:alert] %>
      <div class="flash error"><p><%= flash[:alert] %></p></div>
  <% end %>
  <% if flash[:notice] %>
      <div class="flash notice"><p><%= flash[:notice] %></p></div>
  <% end %>
  <%= yield %>
</div>
<p>

<div class="intro-cartasur">
  <p>
    <%= t 'cartasur.users.profile.introtext' %>
  </p>
</div>
<br />
<div>
  <%= form_for(@user, :html => {:multipart => true}) do |f| %>
      <p><label><%= t 'cartasur.users.profile.username' %>: </label>
        <b> <%= @user.login %></b>
      </p>
      <a href="#" class="form_text_field_label"><%= t 'cartasur.users.profile.photo' %></a>

      <p><%= (@user.image_url.nil? ? (image_tag "/images/default_user.png") : (image_tag "#{@user.image_url.thumb.to_s}")) %>
        <br/>
        <%= f.file_field(:image_url, :size => 15) %>

      <fieldset class="form_text_field_label_fieldset" style="padding: 9px;">


      <p><label ><%= t 'cartasur.users.profile.usertype' %>:</label><br>
        <%= f.text_area(:role, :size=>"20x3", :max=>250,  :value=>@user.role ||  "citizen", :readonly => true,  :class=> 'form_text_field') %>
      </p>
        <p><label ><%= t 'cartasur.users.profile.surname' %>:</label><br>
          <%= f.text_field(:surname, :size => 20, :readonly => true, :class=> 'form_text_field') %>
        </p>
        <p><label ><%= t 'cartasur.users.profile.othernames' %>:</label><br>
          <%= f.text_field(:other_names, :size => 35, :readonly => true, :class=> 'form_text_field') %>
        </p>
        <p><label ><%= t 'cartasur.users.profile.gender' %>:</label><br>
          <%= f.text_field(:gender, :size => 20, :readonly => true, :class=> 'form_text_field') %>
        </p>
      <p><label ><%= t 'cartasur.users.profile.place' %>:</label><br>
        <%= f.text_field(:location, :size => 20, :readonly => true, :class=> 'form_text_field') %>
      </p>

      <p><label ><%= t 'cartasur.users.profile.phonemodel' %>:</label><br>
        <%= f.text_field(:phonemodel, :size => 20, :readonly => true, :class=> 'form_text_field') %>
      </p>
      <p><label ><%= t 'cartasur.users.profile.email' %>:</label><br>
        <%= f.text_field(:email2, :size => 50, :readonly => true, :class=> 'form_text_field') %>
      </p>

      </fieldset>
  <% end %>
</div>
<br />
<h3><%= t 'cartasur.users.profile.questionnaireanswers' %></h3>
<div class="rounded_corners_div" style="background: #f9f9f9; border-width: 1px;">
  <% unless @qn_answers.blank? %>
      <% @qn_questions.each{ |question| %>
          <p><span class="cartasur_question_span"><%= question.text %> </span> <br />
            ﻿<% ans = @qn_answers.where("question_id=#{question.id}").first
                unless ans.nil?
                  item = ans.value
                     if item.nil? %>
                        <span class="cartasur_answer_span"> </span> <br />
                    <% else %>
                        <span class="cartasur_answer_span"><%= ans.value %></span><br />
                    <% end %>

                <% end #unless %>
          </p>
      <% }  %>

      <% else %>
      <p><span class="cartasur_answer_span"><%=  t 'cartasur.users.profile.noanswers' %> </span> <br />
      <% end %>
</div>

 <br />

<div class="intro">
<p>  <a href="http://tinyurl.com/cartAsurQuestionnaire"><%= t 'cartasur.users.show.questionnaire' %> </a> </p>
<p><%= t 'cartasur.users.profile.yourapikey' %>: <%= @user.salt %></p>
</div>

